//
//  ViewController.m
//  view
//
//  Created by Luck on 16/6/6.
//  Copyright © 2016年 yinjiao. All rights reserved.
//

#import "ViewController.h"
#import "TableViewController.h"

@interface ViewController ()
{
    
    NSArray *Data;
}
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    Data = @[
             @"微信",
             @"支付宝",
             @"客服",
             @"其他"
             ];
    
    self.title = @"我的导航标题";
    //导航标题下面的颜色
    self.view.backgroundColor = [UIColor brownColor];
    //self.view.backgroundColor = [UIColor purpleColor];
    //控制刷新
    self.refreshControl = [UIRefreshControl new];
    //刷新的颜色设置
    self.refreshControl.tintColor = [UIColor greenColor];
    //  self.refreshControl.attributedTitle = [[NSAttributedString alloc]initWithString:@"刷新" attributes:@{NSForegroundColorAttributeName:[UIColor greenColor]}];
    
    //设置图片（右上角）
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"1"] style:UIBarButtonItemStylePlain target:self action:@selector(onClick:)];
    //将导航题设置成图片
    UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"3"]];
    self.navigationItem.titleView = iv;
}

- (void)onClick:(id)sender
{
    
    [self.refreshControl endRefreshing];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return Data.count;
    
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
    NSString *imgName = [NSString stringWithFormat:@"%ld",indexPath.row + 1];
    cell.imageView.image = [UIImage imageNamed:imgName];
    //将图片设置成圆形图片
    cell.imageView.layer.cornerRadius = 18;
    cell.imageView.clipsToBounds = YES;
    
    cell.textLabel.text = Data [indexPath.row];
    //cell.textLabel.text = @"测试";
    
    //加箭头
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
    
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    TableViewController *con = [TableViewController new];
    
    [self.navigationController pushViewController:con animated:YES];
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end